<template>
  <view>
    <!-- 公共组件-每个页面必须引入 -->
    <public-module></public-module>
    <u-navbar title="確認訂單" :autoBack="true">
      <view slot="right" class="zuowei">座位：8</view>
    </u-navbar>

    <view class="page_cont">
      <!-- 下單類型 -->
      <view class="order_type_list">
        <view @click="orderType = 0" class="order_type_item">
          <text
            :class="
              orderType === 0 ? 'order_type_text_active' : 'order_type_text'
            "
            >内用</text
          >
        </view>

        <view @click="orderType = 1" class="order_type_item">
          <text
            :class="
              orderType === 1 ? 'order_type_text_active' : 'order_type_text'
            "
            >外帶</text
          >
        </view>

        <view @click="orderType = 2" class="order_type_item">
          <text
            :class="
              orderType === 2 ? 'order_type_text_active' : 'order_type_text'
            "
            >外送</text
          >
        </view>
      </view>

      <!-- 如果是外送才顯示 -->
      <view
        class="order_info_box"
        style="margin-bottom: 20.93rpx; margin-top: 0"
        v-if="orderType === 2"
      >
        <view class="order_info_item">
          <view class="common_title_text"> 店鋪名稱/選擇門店 </view>
          <view class="common_desc_text">
            <img
              style="margin-left: 12px"
              :src="'./static/right_arrow.png'"
              alt=""
              srcset=""
            />
          </view>
        </view>

        <view class="order_info_item">
          <view class="common_title_text"> 請填寫/選擇配送地址 </view>
          <view class="common_desc_text">
            <img
              style="margin-left: 12px"
              :src="'./static/right_arrow.png'"
              alt=""
              srcset=""
            />
          </view>
        </view>

        <view class="order_info_item">
          <view class="common_title_text"> 預計取餐時間 </view>
          <view class="common_desc_text">
            立即取餐
            <img
              style="margin-left: 12px"
              :src="'./static/right_arrow.png'"
              alt=""
              srcset=""
            />
          </view>
        </view>
      </view>

      <!-- 商品卡片 -->
      <view class="good_card">
        <view class="good_card_title">共 8 份商品</view>

        <view
          class="good_info"
          v-for="(_good, index) in isCollect ? goodList.slice(0, 1) : goodList"
          :key="index"
        >
          <img
            class="good_img"
            src="https://img1.baidu.com/it/u=2259593287,4186565444&fm=253&fmt=auto&app=120&f=JPEG?w=1179&h=736"
            alt=""
            srcset=""
          />

          <view class="good_info_content">
            <view class="name"
              ><text> {{ _good.name }}</text>
              <view class="good_curd">
                <img :src="'./static/order/delect.png'" alt="" />

                <!-- 加減商品 -->
                <view class="good_num">
                  <!-- 減號 -->
                  <img :src="'./static/order/minus.png'" alt="" />
                  <text class="num">×{{ _good.num }}</text>
                  <!-- 加號 -->
                  <img :src="'./static/order/plus.png'" alt="" />
                </view>
                <!-- 單價 -->
                <view class="price">$ {{ _good.price }} </view>
              </view>
            </view>
            <view class="remark">備注、溫度 </view>
          </view>
        </view>

        <!-- 點擊展開 收齊按鈕 -->
        <view class="expand_btn" @click="isCollect = !isCollect">
          <view class="expand_btn_text"
            >{{ isCollect ? "點擊展示更多" : "點擊收起" }}
          </view>
          <img
            style="margin-left: 6px"
            :src="
              isCollect
                ? './static/demo/arrow_down.png'
                : './static/demo/arrow_top.png'
            "
            alt=""
            srcset=""
          />
        </view>

        <!-- 使用券 -->
        <view class="coupon_list">
          <view class="coupon_desc"> 使用券 </view>
          <view class="coupon_info">
            無可用券
            <img
              style="margin-left: 6px"
              :src="'./static/right_arrow.png'"
              alt=""
              srcset=""
            />
          </view>
        </view>

        <!-- 備註 -->
        <view class="remark_list">
          <view class="remark_desc"> 備註 </view>

          <u--input
            placeholderStyle="background: rgba(242, 242, 242, 1); padding-left: 12px"
            :border="'none'"
            placeholder="請輸入備注..."
          ></u--input>
        </view>

        <!-- 總價 -->
        <view class="total_price_box">
          <view class="total_price_desc"> 總價 </view>

          <view class="total_price_num"> ￥222 </view>
        </view>
      </view>

      <!-- 下單信息 -->
      <view class="order_info_box">
        <view class="order_info_item">
          <view class="common_title_text"> 用戶名 </view>
          <view class="common_desc_text"> 用戶名稱</view>
        </view>

        <view class="order_info_item">
          <view class="common_title_text"> 預留電話 </view>
          <view class="common_desc_text">
            09XX-XXX-XXX <text style="margin-left: 27rpx">修改</text></view
          >
        </view>

        <!-- 如果為外帶訂單 -->
        <view class="order_info_item" v-if="orderType === 1">
          <view class="common_title_text"> 預計取餐時間 </view>
          <view class="common_desc_text">
            立即取餐
            <img
              style="margin-left: 12px"
              :src="'./static/right_arrow.png'"
              alt=""
              srcset=""
            />
          </view>
        </view>
      </view>

      <!-- 支付方式 -->
      <view class="order_type_card">
        <view class="common_title_h1"> 支付方式 </view>
      </view>
    </view>

    <!-- 提交訂單按鈕 -->
    <view class="order_submit_card">
      <text class="order_total"> 共計</text>
      <text class="order_total_price">$ 300.00</text>
      <button class="order_submit_btn" @click="toOrderSuccess">確認下單</button>
    </view>
  </view>
</template>

<script>
import { mapState } from "vuex";
import base from "@/config/baseUrl.js";
import goodOne from "@/components/module/good";
import specsPopup from "@/components/module/specs-popup";
import fTabbar from "@/components/module/f-tabbar/f-tabbar";
export default {
  components: {
    goodOne,
    specsPopup,
    fTabbar,
  },
  computed: {
    ...mapState(["PrimaryColor"]),
  },
  data() {
    return {
      systemInfo: base.systemInfo,
      //   下單方式，內用，外帶，外送
      orderType: 1,
      //   是否收齊
      isCollect: true,
      //   商品列表
      goodList: [
        {
          name: "商品名稱1",
          num: 1,
          price: 100,
        },
        {
          name: "商品名稱2",
          num: 1,
          price: 100,
        },
      ],
    };
  },
  onLoad(e) {
    // 隐藏原生的tabbar
    uni.hideTabBar();
  },
  onReady() {},
  onShow() {},
  methods: {
    // 調到支付成功頁
    toOrderSuccess() {
      uni.navigateTo({
        url: "/pages/order/OrderSuccess/index",
      });
    },
  },
};
</script>

<style lang="scss" scoped>
page {
  background-color: rgba(255, 255, 255, 1);
}

.zuowei {
  font-family: "Microsoft JhengHei";
  font-size: 27.907rpx;
  font-weight: 400;
}

.page_cont {
  background: rgba(243, 243, 243, 1);
  padding-left: 26.163rpx;
  padding-right: 26.163rpx;
  margin-top: 44px;

  height: calc(100vh - 44px);

  margin-bottom: 12px;
}

.order_type_list {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10.465rpx;
  padding-bottom: 10.465rpx;
}

.order_type_item {
  width: 219.767rpx;
  height: 69.767rpx;
  border-radius: 8.721rpx;
  border: 0.3px;
  display: flex;
  justify-content: center;
  align-items: center;

  color: rgba(115, 115, 115, 1);

  font-family: "Microsoft JhengHei";
  font-size: 34.884rpx;
  font-weight: 400;

  background: rgba(255, 255, 255, 1);
}

.order_type_text_active {
  color: rgba(250, 191, 144, 1) !important;
}

.good_card {
  padding: 20.93rpx;
  background: rgba(255, 255, 255, 1);

  .good_card_title {
    font-family: "Microsoft New Tai Lue";
    font-size: 34.884rpx;
    font-weight: 400;
  }

  .good_info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20.93rpx;
    padding-bottom: 20.93rpx;
  }
  .good_img {
    width: 125.581rpx;
    height: 113.372rpx;
  }

  .good_info_content {
    flex: 1;
    margin-left: 20.93rpx;

    .name {
      font-family: "Microsoft PhagsPa";
      font-size: 27.907rpx;
      color: rgba(0, 0, 0, 1);

      display: flex;
      justify-content: space-between;

      .good_curd {
        display: flex;
        align-items: center;
      }

      .good_num {
        border: 0.3px solid rgba(212, 212, 212, 1);
        // width: 94.186rpx;
        height: 29.651rpx;
        border-radius: 10.465rpx;
        // padding: 6.977rpx;
        padding-left: 10.465rpx;
        padding-right: 10.465rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-left: 10.465rpx;
      }

      .num {
        font-family: "Maven Pro";
        font-size: 24.419rpx;
        padding-left: 5.233rpx;
        padding-right: 5.233rpx;
      }
      .price {
        font-family: "Microsoft PhagsPa";
        font-size: 27.907rpx;
        margin-left: 10.465rpx;
      }
    }

    .remark {
      font-family: "Microsoft PhagsPa";
      font-size: 27.907rpx;
      color: rgba(98, 98, 98, 1);
      margin-top: 20.93rpx;
    }
  }
}

.expand_btn {
  background: rgba(246, 246, 246, 1);
  width: 645.349rpx;
  height: 48.837rpx;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 27.907rpx;

  .expand_btn_text {
    font-family: "Microsoft New Tai Lue";
    font-size: 26.163rpx;
  }
}

.coupon_list {
  padding-left: 20.93rpx;
  padding-top: 34.884rpx;
  padding-bottom: 34.884rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 0.5px solid rgba(109, 109, 109, 0.2);

  .coupon_desc {
    font-family: "Microsoft JhengHei";
    font-size: 27.907rpx;
    font-weight: 400;
  }
  .coupon_info {
    font-family: "Microsoft JhengHei";
    font-weight: 400;
    font-size: 24.419rpx;
    color: rgba(97, 97, 97, 1);
  }
}

.remark_list {
  padding-left: 20.93rpx;
  padding-top: 34.884rpx;
  padding-bottom: 34.884rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 0.5px solid rgba(109, 109, 109, 0.2);
  .remark_desc {
    font-family: "Microsoft JhengHei";
    font-size: 27.907rpx;
    font-weight: 400;
    color: rgba(97, 97, 97, 1);

    margin-right: 69.767rpx;
  }
}
.total_price_box {
  font-family: "Microsoft JhengHei";
  font-size: 27.907rpx;
  font-weight: 400;
  display: flex;
  justify-content: end;
  align-items: center;

  color: rgba(0, 0, 0, 1);

  margin-top: 34.884rpx;
}

.order_info_box {
  padding: 0 20.93rpx 20.93rpx 20.93rpx;
  background: rgba(255, 255, 255, 1);

  margin-top: 20.93rpx;

  .order_info_item {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding-top: 20.93rpx;
  }
}

.order_type_card {
  padding: 20.93rpx;
  background: rgba(255, 255, 255, 1);
  margin-top: 20.93rpx;
}

.order_submit_card {
  position: fixed;
  bottom: 0;
  height: 156.977rpx;
  width: 751.744rpx;
  border: 1px solid rgba(255, 255, 255, 1);
  background: rgba(255, 255, 255, 1);
  display: flex;
  justify-content: end;
  align-items: center;
  padding-right: 34.884rpx;
  border-radius: 8.721rpx;
  .order_total {
    font-family: "Microsoft New Tai Lue";
    font-size: 24.419rpx;
  }

  .order_total_price {
    font-family: "Microsoft New Tai Lue";
    font-size: 27.907rpx;
    color: rgba(247, 154, 77, 1);
  }
  .order_submit_btn {
    background: rgba(247, 154, 77, 1);
    border: 1px solid rgba(247, 154, 77, 1);
    width: 244.186rpx;
    height: 81.977rpx;
    border-radius: 17.442rpx;
    font-family: "Microsoft New Tai Lue";
    font-size: 41.86rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(255, 255, 255, 1);
    margin-left: 20.93rpx;
  }
}
</style>
